package com.ruoyi.web.controller.system;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.enums.BusinessStatus;
import com.ruoyi.common.page.TableDataInfo;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.framework.web.base.BaseController;
import com.ruoyi.system.domain.HatchetAgent;
import com.ruoyi.system.domain.HatchetIssBank;
import com.ruoyi.system.domain.HatchetMerchant;
import com.ruoyi.system.domain.HatchetMoneyChange;
import com.ruoyi.system.domain.HatchetOrderPayment;
import com.ruoyi.system.service.IHatchetAgentService;
import com.ruoyi.system.service.IHatchetIssBankService;
import com.ruoyi.system.service.IHatchetMerchantService;
import com.ruoyi.system.service.IHatchetMoneyChangeService;
import com.ruoyi.system.service.IHatchetOrderPaymentService;
import com.ruoyi.system.service.IHatchetSystemConfigService;
import com.ruoyi.system.vo.AgentMerchantChangeVo;

/**
 * 代理商的收益 
 * 
 * @author xj
 * @date 2019-02-18
 */
@Controller	
@RequestMapping("/system/hatchetMoneyChangeForDLS")
public class HatchetMoneyChangeForDLSController extends BaseController
{
    private String prefix = "system/hatchetMoneyChange";
	@Autowired
	private IHatchetMoneyChangeService hatchetMoneyChangeService;
	@Autowired
	private IHatchetAgentService agentService;
	@Autowired
	private IHatchetMoneyChangeService moneyChangeService; 
	@Autowired
	private IHatchetOrderPaymentService orderPaymentService;
	@Autowired
	private IHatchetMerchantService merchantService; 
	@Autowired
	private IHatchetIssBankService issBankService; 
	@Autowired
	private IHatchetSystemConfigService configService;
	@RequiresPermissions("system:hatchetAgent:view")
	@GetMapping("/{status}")
	public String hatchetMoneyChange(@PathVariable("status") Integer status,ModelMap mmap)
	{
		if (status == 1) {
			 return prefix + "/hatchetMoneyChangeForDLS1";
		} else if (status == 2) {
			 return prefix + "/hatchetMoneyChangeForDLS2";
		} else if (status == 3) {
			return prefix +  "/hatchetMoneyChangeForDLS3";
		} else if (status == 4) {
			//查询代理商基本详情进入提现页面
			HatchetAgent agent = agentService.selectHatchetAgentByNo(getLoginName());
			HatchetIssBank bank = issBankService.selectHatchetIssBankById(agent.getIssbankId());
			agent.setIssbankId(bank.getBankName());
			mmap.put("hatchetAgent", agent);
			return prefix +  "/hatchetMoneyChangeForDLS4";
		//代理商收益列表页面
		} else if (status == 5) {
			return prefix +  "/hatchetMoneyChangeForDLS5";
		} else if (status == 6) {
			return prefix +  "/hatchetMoneyChangeForDLS6";
		} else if (status == 7) {
			return prefix +  "/hatchetMoneyChangeForDLS7";
		}
		return null;
		}
		

	/**
	 * 查询分润记录列表
	 */
	@ResponseBody
	@RequiresPermissions("system:hatchetMoneyChange:list")
	@PostMapping("/fenRunForDLS")
	public TableDataInfo fenRunList(HatchetMoneyChange hatchetMoneyChange) {
		// 查询自己的分润 列表
		hatchetMoneyChange.setUserId(getLoginName());
		hatchetMoneyChange.setSTATUS("10B");
		startPage();
		List<HatchetMoneyChange> list = hatchetMoneyChangeService.selectFenRenChangeList(hatchetMoneyChange);
		for (HatchetMoneyChange hatchetMoneyChange2 : list) {
			//通过订单编号去匹配订单信息
			String orderNo = hatchetMoneyChange2.getPaymentOrderId();
			HatchetOrderPayment orderPayment = orderPaymentService.selectHatchetOrderPaymentByOrder(orderNo);
			if (StringUtils.isNotNull(orderPayment)) {
				hatchetMoneyChange2.setOrderTrxAmt(orderPayment.getTrxAmt());//匹配交易金额
				//匹配手机号
				HatchetMerchant merchant = merchantService.selectHatchetMerchantById(orderPayment.getMerchantId());
				if (StringUtils.isNotNull(merchant)) {
					if (StringUtils.isNotEmpty(merchant.getPHONE())) {
						//手机号加密
//						hatchetMoneyChange2.setMerchantPhone(StringUtils.idCardNoString(merchant.getPHONE(),3));
						hatchetMoneyChange2.setMerchantPhone(merchant.getPHONE());
					}
					hatchetMoneyChange2.setMerName(merchant.getMerchantCnName());
				}
			}
		}
		
		
		return getDataTable(list);
	}
	

	/**
	 * 查询代理商每天的收益
	 */
	@ResponseBody
	@RequiresPermissions("system:hatchetMoneyChange:list")
	@PostMapping("/fenRunForDLSByDay")
	public TableDataInfo fenRunListByDay(HatchetMoneyChange hatchetMoneyChange) {
		// 查询自己的分润 列表
		hatchetMoneyChange.setUserId(getLoginName());
		hatchetMoneyChange.setSTATUS("10B");
		startPage();
		List<HatchetMoneyChange> list = hatchetMoneyChangeService.selectFenRenChangeListByDay(hatchetMoneyChange);
		for (HatchetMoneyChange hatchetMoneyChange2 : list) {
			String formatDate = DateUtils.dateTime(hatchetMoneyChange2.getCreateTime());
			hatchetMoneyChange2.setTime(formatDate);
			hatchetMoneyChange2.setMerName(getSysUser().getUserName());
		}
		return getDataTable(list);
	}
	
	/**
	 * 查询代理商最近一周的收益显示图表
	 */
	@ResponseBody
	@RequiresPermissions("system:hatchetMoneyChange:list")
	@PostMapping("/fenRunForDLSByWeek")
	public List<HatchetMoneyChange> fenRunForDLSByWeek(HatchetMoneyChange hatchetMoneyChange) {
			//获得 一周的每日收益
			List<HatchetMoneyChange> list = new ArrayList<>();;//重新组装每日收益
			hatchetMoneyChange.setUserId(getLoginName());
			//查询一周的数据
			for(int i =-6;i<1;i++) {
				Map<String, Object> params1 = new HashMap<String, Object>();
				params1.put("beginTime", DateUtils.getNextDateStr(i));
				params1.put("endTime", DateUtils.getNextDateStr(i));
				hatchetMoneyChange.setParams(params1);
				hatchetMoneyChange.setSTATUS("10B");
				//测试
	/*			BigDecimal sumFenRenDay = new BigDecimal(""+10*(i+8));*/
				BigDecimal sumFenRenDay = hatchetMoneyChangeService.selectSumFenRenChangeListByDay(hatchetMoneyChange);
				HatchetMoneyChange hatchetMoneyChangeForWeek = new HatchetMoneyChange();
				hatchetMoneyChangeForWeek.setTime(DateUtils.getNextDateStr(i));
				if (StringUtils.isNull(sumFenRenDay)) {
					hatchetMoneyChangeForWeek.setTrxAmt(new BigDecimal("0.00"));	
				} else {
					hatchetMoneyChangeForWeek.setTrxAmt(sumFenRenDay);	
				}
				list.add(hatchetMoneyChangeForWeek);
			}
		return list;
	}
	
	/**
	 * 查询提现记录列表
	 */
	@RequiresPermissions("system:hatchetMoneyChange:list")
	@PostMapping("/tiXianJLForDLS")
	@ResponseBody
	public TableDataInfo tiXianJLForDLS(HatchetMoneyChange hatchetMoneyChange)
	{
		// 查询自己的分润 列表
		hatchetMoneyChange.setUserId(getLoginName());	
		hatchetMoneyChange.setMoneyType("10B");
		startPage();
        List<HatchetMoneyChange> list = hatchetMoneyChangeService.selectHatchetMoneyChangeList(hatchetMoneyChange);
		int stringLength ;
        for (HatchetMoneyChange hatchetMoneyChange2 : list) {
			if (hatchetMoneyChange2.getUserId() != null ) {
				stringLength =hatchetMoneyChange2.getUserId().length();
				if (stringLength == 7 ) {
					hatchetMoneyChange2.setMerType("1");
					HatchetAgent agent=agentService.selectHatchetAgentByNo(hatchetMoneyChange2.getUserId());
					if (agent != null) {
						hatchetMoneyChange2.setMerName(agent.getAgentName());
					}
				}
				if (stringLength == 15 ) {
					hatchetMoneyChange2.setMerType("2");
					HatchetMerchant hatchetMerchant = merchantService.selectHatchetMerchantByNo(hatchetMoneyChange2.getUserId());
					if (hatchetMerchant != null) {
						hatchetMoneyChange2.setMerName(hatchetMerchant.getMerchantCnName());
					}
				}
			}
		}
        return getDataTable(list);
	}
	
	
	// 代理商提交提现请求
	@ResponseBody
	@RequestMapping("/getTixian")
	public Map<String, Object> getTixian(@RequestParam("money") String money) {
		Map<String, Object> map = new HashMap<>();
		try {
			//查询代理商
			HatchetAgent agent = agentService.selectHatchetAgentByNo(getLoginName());
			//获取配置的最大单次提现金额
			String selectValueByCode = configService.selectValueByCode("tixian_max_money");
			BigDecimal maxMoney = new BigDecimal(selectValueByCode);
			BigDecimal b = new BigDecimal(money);
			//提现金额大于最大限制金额
			if (b.subtract(maxMoney).doubleValue()>0) {
				map.put("msg", "单次提现的最大金额不能超过"+maxMoney+"元,请重新输入金额");
				map.put("status",BusinessStatus.FAIL);
				return map;
			}
			if (agent != null) {
				if ("1".equals(agent.getUploadContract())) { 
					map.put("msg", "您的余额账户已被禁止提现,请联系客服处理");
					map.put("status",BusinessStatus.FAIL);
					return map;
				}
				//查询今日提现次数
				int num = moneyChangeService.findCountByAgentNO(agent.getAgentNo(),DateUtils.getNextDateStr(0)); 
				if (num < 1) {
					//变更代理商金额
					BigDecimal oldmoney = agent.getTotalMoney();
					if (oldmoney.subtract(b).doubleValue() < 0) {// 提现金额不能超过现有可提现金额
						map.put("msg", "提现金额不能超过可提现金额！");
						map.put("status", BusinessStatus.FAIL);
					} else {
						BigDecimal nowmoney = oldmoney.subtract(b);
						agent.setTotalMoney(nowmoney);
						//执行提现
						boolean doMoneyChange = moneyChangeService.doMoneyChange(agent, money);
						if (doMoneyChange) {
							map.put("status", BusinessStatus.SUCCESS);
							map.put("msg", "提现成功");
							map.put("nowmoney", nowmoney);
						}else {
							map.put("msg", "提现失败");
							map.put("status",BusinessStatus.FAIL);
							return map;
						}
					}
				} else {
					map.put("msg", "今日已提现1次，请明天再提现！");
					map.put("status",BusinessStatus.FAIL);
					return map;
				}
			} else {
				map.put("msg", "代理商不存在");
				map.put("status",BusinessStatus.FAIL);
				return map;
			}
		} catch (Exception e) {
			e.printStackTrace();
			map.put("msg", "数据异常");
			map.put("status", BusinessStatus.FAIL);
		}
		return map;
	}
	
	
	/**
	 * 代理商查询下属的财务分润信息
	 */
	@ResponseBody
	@RequiresPermissions("system:hatchetMoneyChange:list")
	@PostMapping("/selectUnderMoneyForDLS")
	public TableDataInfo selectUnderMoneyForDLS(AgentMerchantChangeVo agentMerchantChangeVo) {
		//设置查询时间为昨天的时间
		Map<String, Object> params = new HashMap<String, Object>();
		params.put("beginTime", DateUtils.getNextDateStr(-1));
		params.put("endTime", DateUtils.getNextDateStr(-1));
		HatchetAgent agent = agentService.selectHatchetAgentByNo(getLoginName());
		//默认查询下级代理商
		if (StringUtils.isEmpty(agentMerchantChangeVo.getUserType())||"0".equals(agentMerchantChangeVo.getUserType())) {
			HatchetAgent paramAgent = new HatchetAgent();
			paramAgent.setDepartmentCode(StringUtils.likeDepartmentCode(agent.getDepartmentCode()));
			if (StringUtils.isNotEmpty(agentMerchantChangeVo.getUserName())) {
				paramAgent.setAgentName(agentMerchantChangeVo.getUserName());
			}
			if (StringUtils.isNotEmpty(agentMerchantChangeVo.getUserNo())) {
				paramAgent.setAgentNo(agentMerchantChangeVo.getUserNo());
			}
			startPage();
			List<AgentMerchantChangeVo> agentMerchantChangeVoList = agentService.selectUnderAgentMoneyForDLS(paramAgent);
			for (AgentMerchantChangeVo aChangeVo  : agentMerchantChangeVoList) {
				HatchetAgent currentAgent = agentService.selectHatchetAgentById(aChangeVo.getiD());
				
				//组装数据
				aChangeVo.setUserType("代理商");
				//查询用户昨天的总收益
				HatchetMoneyChange hatchetMoneyChange = new HatchetMoneyChange();
				hatchetMoneyChange.setParams(params);
				hatchetMoneyChange.setUserId(aChangeVo.getUserNo());
				hatchetMoneyChange.setSTATUS("10B");
				//查询昨日收益
				BigDecimal yesterdayMoney = moneyChangeService.selectSumFenRenChangeListByDay(hatchetMoneyChange);
				//设置用户昨日收益
				if (StringUtils.isNull(yesterdayMoney)) {
					aChangeVo.setYesterdayMoney(new BigDecimal("0.00"));
				}else {
					aChangeVo.setYesterdayMoney(yesterdayMoney);
				}
				//设置用户总收益
				BigDecimal sumMoney = moneyChangeService.selectSumFenRenChangeByUserId(aChangeVo.getUserNo());
				if (StringUtils.isNull(sumMoney)) {
					aChangeVo.setSumMoney(new BigDecimal("0.00"));
				} else {
					aChangeVo.setSumMoney(sumMoney);
				}
				//---------重庆商务中心活动 1. 查询下级运营商的当日和昨日收益（不包含升级分润）
				//						  2.查询 昨日和当日代理商的直推或间接推荐的并且已激活的用户	
				//1.查询昨天不包含升级的收益
				hatchetMoneyChange.setParams(params);
				BigDecimal yesDayExcludeSjMoney = moneyChangeService.selectSumMoneyByMoneyType(hatchetMoneyChange);
				aChangeVo.setYesDayExcludeSjMoney(yesDayExcludeSjMoney);
				HatchetMerchant merchant = new HatchetMerchant();
				merchant.setParams(params);
				//2.查询昨天全部激活人数
				merchant.setDepartmentCode(StringUtils.likeDepartmentCode(currentAgent.getDepartmentCode()));
				//设置查询绑卡认证用户
				merchant.setIsActive("03");
				Long yesDayAllMerCount = merchantService.selectActivHatchetMerchantCountForDLS(merchant);
				aChangeVo.setYesDayAllMerCount(yesDayAllMerCount);
				//3.查询昨天直推激活的人数
				merchant.setAgentId(aChangeVo.getiD());
				Long yesDayDirectMerCount = merchantService.selectActivHatchetMerchantCountForDLS(merchant);
				aChangeVo.setYesDayDirectMerCount(yesDayDirectMerCount);
				//日期设置为今天
				Map<String, Object> params1 = new HashMap<String, Object>();
				params1.put("beginTime", DateUtils.getNextDateStr(0));
				params1.put("endTime", DateUtils.getNextDateStr(0));
				//4.查询今天不包含升级的收益
				
				hatchetMoneyChange.setParams(params1);
				BigDecimal toDayExcludeSjMoney = moneyChangeService.selectSumMoneyByMoneyType(hatchetMoneyChange);
				aChangeVo.setToDayExcludeSjMoney(toDayExcludeSjMoney);
				//5.查询今天全部激活人数 
				merchant.setParams(params1);
				merchant.setDepartmentCode(StringUtils.likeDepartmentCode(currentAgent.getDepartmentCode()));
				merchant.setAgentId("");
				Long toDayAllMerCount = merchantService.selectActivHatchetMerchantCountForDLS(merchant);
				aChangeVo.setToDayAllMerCount(toDayAllMerCount);
				//6.查询今天直推激活的人数
				merchant.setAgentId(aChangeVo.getiD());
				Long toDayDirectMerCount = merchantService.selectActivHatchetMerchantCountForDLS(merchant);
				aChangeVo.setToDayDirectMerCount(toDayDirectMerCount);
				//-----------结束重庆商务中心活动
			
			}
			return getDataTable(agentMerchantChangeVoList);
			//查询间接（全部）商户
		}else {
			//查询下属经纪人
			HatchetMerchant paramHatchetMerchant = new HatchetMerchant();
			//查询所有
			paramHatchetMerchant.setDepartmentCode(StringUtils.likeDepartmentCode(agent.getDepartmentCode()));
		/*	paramHatchetMerchant.setAgentId(agent.getID());*/
			paramHatchetMerchant.setLEVEL("3");
			if (StringUtils.isNotEmpty(agentMerchantChangeVo.getUserName())) {
				paramHatchetMerchant.setMerchantCnName(agentMerchantChangeVo.getUserName());
			}
			if (StringUtils.isNotEmpty(agentMerchantChangeVo.getUserNo())) {
				paramHatchetMerchant.setMerchantNo(agentMerchantChangeVo.getUserNo());
			}
			startPage();
			List<AgentMerchantChangeVo> agentMerchantChangeVoList = merchantService.selectUnderMoneyForDLS(paramHatchetMerchant);
			for (AgentMerchantChangeVo aChangeVo : agentMerchantChangeVoList) {
				aChangeVo.setUserType("经纪人");
				//商户的昨天收益
				HatchetMoneyChange hatchetMoneyChange = new HatchetMoneyChange();
				hatchetMoneyChange.setParams(params);
				hatchetMoneyChange.setUserId(aChangeVo.getUserNo());
				//查询昨日收益
				hatchetMoneyChange.setSTATUS("10B");
				BigDecimal yesterdayMoney = moneyChangeService.selectSumFenRenChangeListByDay(hatchetMoneyChange);
				//设置用户昨日收益
				if (StringUtils.isNull(yesterdayMoney)) {
					aChangeVo.setYesterdayMoney(new BigDecimal("0.00"));
				}else {
					aChangeVo.setYesterdayMoney(yesterdayMoney);
				}
				//设置用户总收益
				BigDecimal sumMoney = moneyChangeService.selectSumFenRenChangeByUserId(aChangeVo.getUserNo());
				if (StringUtils.isNull(sumMoney)) {
					aChangeVo.setSumMoney(new BigDecimal("0.00"));
				} else {
					aChangeVo.setSumMoney(sumMoney);
				}
			}
		return getDataTable(agentMerchantChangeVoList);
		}
	}
	
	/**
	 * 收益分析（代理商查询下属贡献的收益）
	 */
	@ResponseBody
	@RequiresPermissions("system:hatchetMoneyChange:list")
	@PostMapping("/selectMoneyAnalyze")
	public TableDataInfo selectMoneyAnalyze(AgentMerchantChangeVo agentMerchantChangeVo) {
		//查询当月总收益
		Map<String, Object> params = new HashMap<String, Object>();
		params.put("beginTime", DateUtils.getMonth());//获取当月第一天
		HatchetAgent agent = agentService.selectHatchetAgentByNo(getLoginName());
		//默认查询下级代理商
		if (StringUtils.isEmpty(agentMerchantChangeVo.getUserType())||"0".equals(agentMerchantChangeVo.getUserType())) {
			HatchetAgent paramAgent = new HatchetAgent();
			paramAgent.setParentId(agent.getID());
			if (StringUtils.isNotEmpty(agentMerchantChangeVo.getUserName())) {
				paramAgent.setAgentName(agentMerchantChangeVo.getUserName());
			}
			if (StringUtils.isNotEmpty(agentMerchantChangeVo.getUserNo())) {
				paramAgent.setAgentNo(agentMerchantChangeVo.getUserNo());
			}
			startPage();
			List<AgentMerchantChangeVo> agentMerchantChangeVoList = agentService.selectUnderAgentMoneyForDLS(paramAgent);
			for (AgentMerchantChangeVo aChangeVo  : agentMerchantChangeVoList) {
				//组装数据
				aChangeVo.setUserType("代理商");
				//查询用户当月的收益贡献
				//1).查询该代理商下面的所有商户
				HatchetMerchant merchant = new HatchetMerchant();
				merchant.setDepartmentCode(StringUtils.likeDepartmentCode(aChangeVo.getDepartmentCode()));
				List<HatchetMerchant> merchants = merchantService.selectHatchetMerchantForDLS(merchant);
				List<String> merchantIds = new ArrayList<>();
				for (HatchetMerchant hatchetMerchant : merchants) {
					merchantIds.add(hatchetMerchant.getID());
				}
				
				HatchetMoneyChange moneyChange = new HatchetMoneyChange();
				if (StringUtils.isNotEmpty(merchantIds)) {
					moneyChange.setMerchantIds(merchantIds);
				}
				moneyChange.setUserId(agent.getAgentNo());
				moneyChange.setSTATUS("10B");
				//设置总贡献
				BigDecimal sumMoneyAnalyze = moneyChangeService.selectMoneyAnalyze(moneyChange);//历史总总贡献
				if (StringUtils.isNull(sumMoneyAnalyze)) {
					aChangeVo.setSumMoneyAnalyze("0.00");
				}else {
					aChangeVo.setSumMoneyAnalyze(sumMoneyAnalyze+"");
				}
				//设置月贡献
				moneyChange.setParams(params);
				BigDecimal monthMoneyAnalyze = moneyChangeService.selectMoneyAnalyze(moneyChange);//当月总贡献
				if (StringUtils.isNull(monthMoneyAnalyze)) {
					aChangeVo.setMonthMoneyAnalyze("0.00");
				}else {
					aChangeVo.setMonthMoneyAnalyze(monthMoneyAnalyze+"");
				}
			}
			return getDataTable(agentMerchantChangeVoList);
			//查询直接商户
		}else {
			//查询代理商下面的经纪人商户
			HatchetMerchant paramHatchetMerchant = new HatchetMerchant();
			paramHatchetMerchant.setAgentId(agent.getID());
			paramHatchetMerchant.setLEVEL("3");
			if (StringUtils.isNotEmpty(agentMerchantChangeVo.getUserName())) {
				paramHatchetMerchant.setMerchantCnName(agentMerchantChangeVo.getUserName());
			}
			if (StringUtils.isNotEmpty(agentMerchantChangeVo.getUserNo())) {
				paramHatchetMerchant.setMerchantNo(agentMerchantChangeVo.getUserNo());
			}
			//通过身份证号查询代理商的商户身份
			/*HatchetMerchant paramMerchant = new HatchetMerchant();
			paramMerchant.setIdCardNumber(agent.getIdCardNo());
			List<HatchetMerchant> agentMerchantList = hatchetMerchantService.selectHatchetMerchantList(paramMerchant);*/
			startPage();
			List<AgentMerchantChangeVo> agentMerchantChangeVoList = merchantService.selectUnderMoneyForDLS(paramHatchetMerchant);
			for (AgentMerchantChangeVo aChangeVo : agentMerchantChangeVoList) {
				//总收益
				if (StringUtils.isNotEmpty(aChangeVo.getSumMoneyAnalyze())) {
					String[] sumSplit = aChangeVo.getSumMoneyAnalyze().split("/");
					Double sumMoney = 0.00; 
					for (int i = 0; i < sumSplit.length; i++) {
						sumMoney = sumMoney + Double.parseDouble(sumSplit[i]);
					}
						aChangeVo.setSumMoneyAnalyze(sumMoney+"");
				} else {
					aChangeVo.setSumMoneyAnalyze("0.0");
				}
				//月收益
				if (StringUtils.isNotEmpty(aChangeVo.getMonthMoneyAnalyze())) {
					 String[] monSplit = aChangeVo.getMonthMoneyAnalyze().split("/");
					 Double monMoney=0.00;
					 for (int i = 0; i < monSplit.length; i++) {
						 monMoney = monMoney + Double.parseDouble(monSplit[i]);
						}
						aChangeVo.setMonthMoneyAnalyze(monMoney+"");
				}else {
					aChangeVo.setMonthMoneyAnalyze("0.0");
				}
				/*boolean flag = false;
				//一个身份证可能有多个商户账号
				if (StringUtils.isNotEmpty(agentMerchantList)) {
					//判断待升级的用户的推荐人手机号是否和代理商的手机号一致
					for (HatchetMerchant hatchetMerchant2 : agentMerchantList) {
						//如果代理商商户的手机号和带升级用户的推荐人手机号一致，说明是代理商的直推用户
						if (aChangeVo.getParentPhone().equals(hatchetMerchant2.getPHONE())) {
							flag =true;
						}
					}
				}*/
				//是直接用户
				/*if (flag) {
					aChangeVo.setUserType("直接经纪人");
				} else {
					aChangeVo.setUserType("间接经纪人");
				}*/
			}
		return getDataTable(agentMerchantChangeVoList);
		}
	}
	
	
}